package com.example.pathprotectsystem.utils;

import java.util.HashMap;

public class ShuiniCentCalculateUtil {
    private static int[][] a = {
            {50,12,50,5,100,8,10,1,50,4,2,9,50,5},
            {100,25,100,12,500,17,100,3,100,11,10,19,100,8},
            {300,33,300,17,1000,27,500,5,300,15,20,30,500,10},
            {500,44,500,23,3000,55,1000,7,500,21,60,60,1000,16},
            {700,55,700,29,5000,65,2000,10,700,27,100,70,5000,33},
            {10001,65,10001,35,10001,75,10001,12,10001,35,10001,80,10001,42}
    };
    private static HashMap<String,Integer> m = new HashMap<>(){{
        put("板角断裂",0);
        put("边角裂缝",2);
        put("交叉裂缝和破碎版",4);
        put("接缝料损坏",6);
        put("边角剥落",8);
        put("坑洞",10);
        put("表面纹裂",12);
        put("线裂",12);
        put("层状剥落",12);
        put("错台",12);
        put("拱胀",12);
        put("唧浆",12);
        put("路框差",12);
        put("沉陷",12);
    }};

    public static int getDownCent(String damageType,double damageP){
        int cent = 0;
        int col = m.get(damageType);
        for(int i=0;i<6;i++){
            if(damageP*100 < a[i][col]){
                if(col==0||col==2||col==6||col==8||col==10){
                    cent+=a[i][col+1];
                    break;
                }
                else{
                    if(i==0)break;
                    cent+=a[i-1][col+1];
                    break;
                }
            }
        }
        return cent;
    }

}
